package cn.doit.common

import cn.doit.config.DolphinConfig
import org.apache.spark.{SparkConf, SparkContext}
import cn.doit.common.DolphinEnum._

object DolphinAppComm {
  /**
    * 封装创建sparkContext实例
    */

  def creatSparkContext(appName:String,params:Map[String,String]=Map.empty)={
    val conf = new SparkConf()
      conf.setAppName(appName)

    if (DolphinConfig._power.equals(local.toString)){//运行模式的开关
      conf.setMaster("local[*]")
    }

  /**封装用户传递进来的参数*/
    params.foreach{case (key,value)=>conf.set(key,value)}
    new SparkContext(conf)


  }

}
